#define _CRT_SECURE_NO_WARNINGS 1
#include "string.h"

void test_string01()
{
	xsc::string str1;
	const xsc::string str2("123");
	xsc::string str3("hello world");

	/*std::cout << str2[0] << std::endl;
	std::cout << str3[0] << std::endl;

	std::cout << str2.at(2) << std::endl;*/

	std::cout << str1.size() << std::endl;
	std::cout << str2.size() << std::endl;
	std::cout << str3.size() << std::endl;

	std::cout << str1.empty() << std::endl;
	std::cout << str2.empty() << std::endl;
}

void test_string02()
{
	/*xsc::string s("123");

	std::cout << s.size() << std::endl;
	std::cout << s.capacity() << std::endl;

	s.resize(20,'x');
	std::cout << s.size() << std::endl;
	std::cout << s.capacity() << std::endl;*/

	xsc::string str("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;

	str.reserve(40);
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;

	str.clear();
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;
}

void test_string03()
{
	xsc::string str("hello world");
	std::cout << str.c_str() << std::endl;
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;

	//str.push_back('x');
	str.insert(0,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
	std::cout << str.c_str() << std::endl;
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;
}

void test_string04()
{
	xsc::string str("hello world");
	std::cout << str.c_str() << std::endl;
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;

	//str.append("sss");
	str += "xxxxx";
	std::cout << str.c_str() << std::endl;
	std::cout << str.size() << std::endl;
	std::cout << str.capacity() << std::endl;

	str.erase(2);
	std::cout << str.c_str() << std::endl;
	std::cout << str.size() << std::endl;
}

void test_string05()
{
	std::string str("hello world");
	std::cout << str.size() << std::endl;

	str.erase(4,3);
	std::cout << str << std::endl;
	std::cout << str.size() << std::endl;

	std::cout << std::endl;

	xsc::string str1("hello world");
	std::cout << str1.c_str() << std::endl;
	std::cout << str1.size() << std::endl;

	str1.erase(4,3);
	std::cout << str1.c_str() << std::endl;
	std::cout << str1.size() << std::endl;
}

void test_string06()
{
	const xsc::string str("hello world");
	for (auto ch : str)
	{
		ch += 2;
		std::cout << ch << " ";
	}

	auto it = str.begin();
	/*while (it != str.end())
	{
		*it += 2;
		std::cout << *it << " ";
		++it;
	}*/
}

void test_string07()
{
	xsc::string str("hello world");
	/*xsc::string copy(str);

	std::cout << str.c_str() << std::endl;
	std::cout << copy.c_str() << std::endl;

	xsc::string str2;
	str2 = copy;
	std::cout << str2.c_str() << std::endl;*/
	std::cin >> str;
	std::cout << str;
}

void test_string08()
{
	xsc::string str("hello world");

	std::string str1("hello world");

	xsc::string sub = str.substr(6);
	std::cout << sub<<std::endl;
	std::cout << sub.size()<<std::endl;

	std::string sub1 = str1.substr(6);
	std::cout << sub1<<std::endl;
	std::cout << sub1.size()<<std::endl;
}

void test_string09()
{
	xsc::string str1("hello wrold!!!!!!");
	std::cout << str1.size() << std::endl;
	std::cout << str1.capacity() << std::endl;

	xsc::string str2("12");
	std::cout << str2.size() << std::endl;
	std::cout << str2.capacity() << std::endl;

	str2 = str1;
	std::cout << str2.size() << std::endl;
	std::cout << str2.capacity() << std::endl;
}

int main()
{
	test_string09();
	return 0;
}


//int main()
//{
//	test_string06();
//
//	/*std::string str("hello world");
//	std::cout << str.size() << std::endl;
//
//	str.erase(2);
//	std::cout << str << std::endl;
//	std::cout << str.size() << std::endl;*/
//
//
//
//	/*std::string s("123");
//
//	std::cout << s.size() << std::endl;
//	std::cout << s.capacity() << std::endl;
//
//	s.resize(20);
//	std::cout << s.size() << std::endl;
//	std::cout << s.capacity() << std::endl;*/
//
//
//	/*std::string str("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//	std::cout << str.size() << std::endl;
//	std::cout << str.capacity() << std::endl;
//
//	str.reserve(40);
//	std::cout << str.size() << std::endl;
//	std::cout << str.capacity() << std::endl;*/
//	return 0;
//}